<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateO2oShopTable1554107742 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $prefix = config('ibrand.app.database.prefix', 'ibrand_');
        if (!Schema::hasTable($prefix.'o2o_shop')) {
            // Create table for storelocator
            Schema::create($prefix.'o2o_shop', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name')->unique();/*门店名*/
                $table->integer('city_id')->unsigned();/*城市ID*/
                $table->string('address')->nullable();/*地址*/
                $table->string('phone')->nullable();/*联系电话*/
                $table->boolean('top')->default(false);/*置顶*/
                $table->string('img')->nullable();/*门店图*/
                $table->string('img_url')->nullable();/*门店图URL*/
                $table->string('tag')->nullable();/*标签 序列化*/
                $table->string('code')->nullable();/*门店代码*/
                $table->string('type')->nullable();/*门店类型*/
                $table->string('lat')->nullable();/*经度*/
                $table->string('lng')->nullable();/*维度*/
                $table->boolean('is_enable')->default(false);/*是否启用*/
                $table->timestamps();
            });
            Schema::create($prefix.'o2o_city', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name')->unique();/*城市名*/
                $table->string('lat')->nullable();/*经度*/
                $table->string('lng')->nullable();/*维度*/
                $table->string('letter')->nullable();/*首字母*/
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $prefix = config('ibrand.app.database.prefix', 'ibrand_');
        Schema::drop($prefix.'o2o_shop');
        Schema::drop($prefix.'o2o_city');
    }
}